home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / software / temacd / godfather / TGF_069.exe / $INSTDIR / Scripts / 05 regex.sct < prev    next >
Encoding:
Text File  |  2005-02-06  |  731 b   |  36 lines

  1. // simple demo of regular expressions
  2. // will remove the first 2 words of title field if they exist
  3. // syntax reference http://regexpstudio.com/TRegExpr/Help/RegExp_Syntax.html
  4. program regex;
  5.  
  6. var
  7.   sTmp: string;
  8.   bUpdated: boolean;
  9.  
  10. begin
  11.  
  12.   if not tg_Init then exit; // no rows get out
  13.  
  14.   repeat
  15.  
  16.     bUpdated := false;
  17.  
  18.     sTmp := tg_GetField( 'Title' );
  19.  
  20.     if sys_RegexFind( sTmp, '.*? .*? ' ) then begin
  21.        tg_setField( 'Title', sys_RegexReplace( sTmp, '.*? .*? ', '', false ) );
  22.        bUpdated := true;
  23.     end;
  24.  
  25.     if bUpdated then begin
  26.        tg_setSkip( false );
  27.        tg_SetResult( 'OK' );
  28.     end else begin
  29.        tg_setSkip( true );
  30.     end;
  31.  
  32.   until not tg_Skip;
  33.  
  34. end.
  35.  
  36.